<template>
	<view class="" style="background: #FFF;    min-height: 100vh;">
		<view class="mainBox">
			<image src="../../static/home/icon1.png" mode="" class="topImg"></image>
			<!-- 输入框 -->

			<u--input placeholder="请输入内容" border="surround" v-model="value" suffixIcon="search" @blur="change"></u--input>

			<!-- 按钮框 -->

			<view class="itemBox">
				<view class="itemBtn" @click="contest()">
					<image src="../../static/home/icon2.png" mode=""></image>
					<view class="itemBtnText">竞赛报名</view>
				</view>

				<view class="itemBtn" @click="questionclick()">
					<image src="../../static/home/icon3.png" mode=""></image>
					<view class="itemBtnText">试题自测</view>
				</view>
				<view class="itemBtn" @click="toTopiclearning()">
					<image src="../../static/home/icon4.png" mode=""></image>
					<view class="itemBtnText">专题学习</view>
				</view>
			</view>
			<!-- 列表 -->
			<view class="listTitle">数学文化</view>

			<view class="list" v-for="(item, index) in list" :key="index" @click="toDetails(item)">
				<view class="listText">{{ item.title }}</view>
				<view class="listTime">{{ item.createTime }}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			value: '',
			list: []
		};
	},
	mounted() {
		this.dataList();
	},
	methods: {
		dataList() {
			const request = this.$http({
				url: `maths/list?pageNo=1&pageSize=1000`,
				method: 'POST'
			}).then(res => {
				if ((res.code = 200)) {
					this.list = res.data.records;
					// this.listclick()
				} else {
					uni.showToast({
						title: res.msg || '系统异常,请稍后重试',
						icon: 'none',
						duration: 2000
					});
				}
			});
			return request;
		},
		//跳转竞赛报名
		contest() {
			uni.navigateTo({
				url: '../../subpkg/enroll/enroll'
			});
		},
		//跳转试题自测
		questionclick() {
			uni.switchTab({
				url: '../news/index'
			});
		},
		// 输入框值发生改变的时候
		change(e) {
			console.log('change', e);
			uni.navigateTo({
				url: '../../subpkg/searchResult/searchResult?item=' + e
			});
		},
		//跳转到专题学习
		toTopiclearning() {
			console.log(111);
			uni.navigateTo({
				url: '../../subpkg/topicLearning/index'
			});
		},
		// 跳到详情
		toDetails(data) {
			let currentSite = JSON.stringify(data);
			uni.navigateTo({
				url: '../../subpkg/mathsdetails/mathsdetails?item=' + currentSite
			});
		},
		itemClick() {
			uni.showToast({
				title: '暂未开通',
				icon: 'error'
				// image: "/static/service/time.png"
			});
		}
	},
	// 下拉刷新
	onPullDownRefresh() {
		(this.list = []),
			this.dataList().finally(() => {
				uni.stopPullDownRefresh();
			});
	}
};
</script>

<style lang="scss" scoped>
.mainBox {
	padding: 26rpx 32rpx;

	.topImg {
		height: 326rpx;
		width: 100%;
		margin-bottom: 16rpx;
	}

	.searchInput {
		margin-bottom: 15rpx;
	}

	.itemBox {
		margin-top: 15rpx;
		width: 100%;
		height: 176rpx;
		background: #ffffff;
		box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.08);
		border-radius: 12rpx;
		margin-bottom: 37rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;

		.itemBtn {
			text-align: center;

			image {
				width: 75rpx;
				height: 75rpx;
				margin-bottom: 15rpx;
			}

			.itemBtnText {
				font-size: 24rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #27282e;
				line-height: 36rpx;
			}
		}
	}

	// 列表
	.listTitle {
		font-size: 36rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #27282e;
		line-height: 36rpx;
		margin-bottom: 16rpx;
	}

	.list {
		padding: 24rpx;
		height: 156rpx;
		background: #ffffff;
		box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(29, 82, 130, 0.06);
		border-radius: 16rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-bottom: 24rpx;

		.listText {
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #2a3447;
			line-height: 48rpx;
		}

		.listTime {
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #7b7e8f;
			line-height: 24rpx;
		}
	}
}
</style>
